package org.sam.swing.utils;

import javax.swing.Action;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

/**
 * 操作功能助手
 * @author sam
 *
 */
public class ActionUtil {

	/**
	 * 生成弹出式菜单
	 * @param actions 操作集合
	 * @return 传入null返回null
	 */
	public static JPopupMenu buildMenu(Action[] actions) {
		if (actions == null)
			return null;
		
		JPopupMenu menu = new JPopupMenu();
		for(Action action: actions) {
			menu.add(new JMenuItem(action));
		}
		
		return menu;
	}
}
